<?php

use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminRolesTable extends Migration
{
    private $table = 'admin_roles';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable($this->table)) {
            Schema::create($this->table, function (Blueprint $table) {
                $table->charset = 'utf8';
                $table->collation = 'utf8_general_ci';
                $table->comment = '管理员角色表';
                $table->increments('id')->comment('主键');
                $table->string('identifier', 100)->unique()->comment('角色编号');
                $table->string('name', 100)->unique()->comment('角色名称');
                $table->unsignedSmallInteger('number')->default(0)->comment('该角色拥有管理员数量限制,0为不限制');
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasTable($this->table)) {
            Schema::dropIfExists($this->table);
        }
    }
}
